<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class OrderSettlement extends Model
{
    protected $table = 'mckj_org_order_settlement';

    const UPDATED_AT = 'updated_time';

    const CREATED_AT = 'created_time';

    const STATUS_PROCESSING = 1;
    const STATUS_AUDITING = 2;
    const STATUS_AUDITED = 3;
    const STATUS_REMIT = 4;

    public static $statusText = [
        self::STATUS_PROCESSING => '结算中',
        self::STATUS_AUDITING => '审核中',
        self::STATUS_AUDITED => '已审核',
        self::STATUS_REMIT => '已打款',
    ];

    public function getStatusTextAttribute()
    {
        return self::$statusText[$this->status] ?? '';
    }


    public function divided()
    {
        return $this->hasMany(OrderSettlementDivid::class, "settlement_id");
    }

    public function organization()
    {
        return $this->belongsTo(Organization::class, 'org_id');
    }

    public function organizationUser()
    {
        return $this->belongsTo(OrganizationUser::class, 'org_uid');
    }
}
